﻿using VitCode.Castle.Entities;

namespace VitCode.WorkFlow.Entities
{
    public class WorkItem : BaseEntity
    {
        public const string FLAG_START = "Start",
                            FLAG_DOING = "Doing",
                            FLAG_END = "End",
                            FIX_OPTIONAL = "Optional",
                            FIX_NEED = "Need",
                            FIX_READ_ONLY = "ReadOnly";
                            


        public virtual Activity Activity { get; set; }
        public virtual int LevelNum { get; set; }
        public virtual Role OperateRole { get; set; }
        public virtual string TargetUrl { get; set; }
        public virtual string TargetClassName { get; set; }
        public virtual string Name { get; set; }

        /// <summary>
        /// 传递的参数(eg: name=haha;address=123;)
        /// </summary>
        public virtual string Prams { get; set; }

        /// <summary>
        /// 标记(工作流的开端,结束或过程中)
        /// </summary>
        public virtual string Flag { get; set; }

        public virtual string FixType { get; set; }
        public virtual string OrderString { get; set; }
        public virtual int FlowId { get; set; }


        /// <summary>
        /// 重写Equals方法
        /// </summary>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(obj, this))
                return true;
            if (obj == null)
                return false;
            var sObj = obj as WorkItem;
            return sObj != null &&
                   (sObj.Id == m_Id || (sObj.Activity == Activity && sObj.Memo == Memo && sObj.LevelNum == LevelNum));
        }

        /// <summary>
        /// 重写GetHashCode方法
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 37;
            hash = 24*hash*m_Id.GetHashCode();
            return hash;
        }
    }
}